﻿using Magicodes.Pay.WeChat;
using Magicodes.Pay.WeChat.Pay.Dto;
using Microsoft.AspNet.Identity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Security.Claims;
using System.Web;
using System.Web.Http;

namespace CarterWechatServer.WebApi.Controllers
{
    /// <summary>
    /// 支付控制器
    /// </summary>
    [Authorize]
    public class PayController : ApiController
    {

        public MiniProgramPayOutput Post(MiniProgramPayInput input)
        {
            ClaimsIdentity identity = HttpContext.Current.User.Identity as ClaimsIdentity;
            input.OpenId = identity.FindFirstValue("openId");
            input.Body = "RobinChan微信小程序支付";
            input.Attach = "微信小程序点餐支付";
            input.SpbillCreateIp = "60.204.184.247";
            input.TotalFee = 0.01m;

            MiniProgramPayOutput output = new WeChatPayApi().MiniProgramPay(input);

            return output;
        }
    }
}
